package com.lazyben;

import com.lazyben.router.PushServerRouter;
import com.lazyben.server.PushServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class PushServerApplication implements CommandLineRunner {
    @Autowired
    private PushServer pushServer;

    @Autowired
    private PushServerRouter pushServerRouter;

    public static void main(String[] args) {
        SpringApplication.run(PushServerApplication.class, args);
    }

    /**
     * 在项目启动时，启动netty server。
     * CommandLineRunner用于在项目启动时加载或者预先完成某些动作
     *
     * @param args args
     * @throws Exception exception
     */
    @Override
    public void run(String... args) throws Exception {
        pushServerRouter.start();
        pushServer.start();
    }
}
